<?php
/**
 * Created by PhpStorm.
 * User: cabbage
 * Date: 2018/11/8
 * Time: 5:16 PM
 */

namespace fast;

class Redis
{
    private static $_instance = null; //静态实例

    private function __construct()
    { //私有的构造方法
        self::$_instance = new \Redis();
        self::$_instance->connect(config('Redis.host'),config('Redis.port'));
        if (!empty(config('Redis.password'))) {
            self::$_instance->auth(config('Redis.password'));
        }
        self::$_instance->select(config('Redis.select'));
    }

    //获取静态实例
    public static function getRedis()
    {
        if (!self::$_instance) {
            new self;
        }

        return self::$_instance;
    }

    /*
     * 禁止clone
     */
    private function __clone()
    {
    }


}